package com.cheyunkeji.er.adapter.evaluate;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.adapter.MyBaseAdapter;
import com.cheyunkeji.er.bean.evaluate.CarArchive;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/** Created by Michael on 2017/2/16 15:45. */
public class CarArchiveAdapter extends MyBaseAdapter {

  private static final String TAG = CarArchiveAdapter.class.getSimpleName();

  public CarArchiveAdapter(ArrayList<CarArchive> dataList, Context context) {
    super(dataList, context);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    final ViewHolder holder;
    if (convertView == null) {
      convertView =
          LayoutInflater.from(context).inflate(R.layout.er_evaluate_car_archive_lv_item, null);
      holder = new ViewHolder(convertView);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    if (position % 2 != 0) convertView.setBackgroundColor(Color.parseColor("#fbfbfb"));
    else convertView.setBackgroundColor(Color.parseColor("#ffffff"));

    CarArchive itemBean = (CarArchive) dataList.get(position);

    holder.tvVinCode.setText(itemBean.getVin());
    holder.tvCarType.setText("车系车型：" + itemBean.getSeries() + itemBean.getSpec());
    holder.tvPlateNumber.setText("车牌号：" + itemBean.getPlate());
    return convertView;
  }

  static class ViewHolder {
    @BindView(R.id.tv_vin_code)
    TextView tvVinCode;

    @BindView(R.id.tv_car_type)
    TextView tvCarType;

    @BindView(R.id.tv_plate_number)
    TextView tvPlateNumber;

    ViewHolder(View view) {
      ButterKnife.bind(this, view);
    }
  }
}
